<%
import time as t
start_time = t.time()
simple_type = filetype.split('/')[0].lower()
file_short_src = 'http://p.hydra.ws/' + short_key
file_external_src = '/api/file/' + short_key
stylesheets = tuple(('pygments.css', ))

# Opengraph & twitter cards
if simple_type == 'image':
    og_image = '/api/file/' + key
    card_type = 'photo'
elif filetype.lower() == 'text/x-sh':
    filetype = 'application/x-sh'
    simple_type = 'text'
elif simple_type == 'text' or filetype in ('application/json', 'application/php'):  # temporary workaround
    card_type = 'text'
    simple_type = 'text'
    filetype = filetype.replace('application', 'text')
end  # (if)

%>
% include(top)

<div class="pure-g">
<div class="pure-u-1 pure-u-lg-1-8"></div>
<div class="pure-u-1 pure-u-lg-3-4 content">
	<h1>{{title}}</h1>
	<div class="pure-u-1" id="infobox">
		<p>By {{user}} {{time}}. \\
% if filename:
 Filename: {{filename}} \\
% end
 Mimetype: {{filetype}}</p><p>\\
% if int(expires) == 0:
Expires: Never
% else:
%     expires = t.strftime("%D %H:%M:%S", t.localtime(int(expires)))
Expires: <span id="expires">{{expires}}</span>
% end
; Size:{{filesize}} bytes; Views:{{views}} <a href="{{file_external_src}}" download="{{title}}" type="{{filetype}}">Download Paste</a></p>
<p>Share URL:<input type="text" id="share-url" value="http://paste.hydra.ws/p/{{short_key}}" /> &nbsp;Short URL: <input type="text" id="short-url" value="{{file_short_src}}" /> &nbsp;</p></div>
	<div id="paste" class="pure-u-1">
% if simple_type == 'text' or filetype in ('application/json', 'application/php'):
%    if 'php' in filetype:
%        filetype = 'text/x-php'
%    end  # (if)
%    from pygments.lexers import get_lexer_for_mimetype
%    from pygments.formatters import HtmlFormatter
%    from pygments import highlight
%    from pygments.styles import get_style_by_name
%    
%    file_obj = open(file_internal_src)
%    my_style = get_style_by_name('pastie')
%    
%    mylex = get_lexer_for_mimetype(filetype)
%    #formatter = HtmlFormatter(linenos = True, style=my_style, cssclass='pastecode', full=True)
%    formatter = HtmlFormatter(linenos=True, nowrap=False, cssclass='pastecode')
%    formatted_text = highlight(file_obj.read(), mylex, formatter)
{{!formatted_text}}
% elif simple_type == 'image':
		<img src="{{file_external_src}}" alt="{{title}}" />\\
% elif simple_type == 'video':
		<video src="{{file_external_src}}" type="{{filetype}}" preload controls>
			<h2>Sorry, your old-ass browser doesn't support <code>video</code> tags.</h2>
			<p>How about <a href="http://browsehappy.com/">updating?</a></p>
		</video>\\
% elif simple_type == 'audio':
		<audio src="{{file_external_src}}" type="{{filetype}}" preload controls>
			<h2>Sorry, your old-ass browser doesn't support <code>audio</code> tags.</h2>
			<p>How about <a href="http://browsehappy.com/">updating?</a></p>
		</audio>\\
% elif filetype == 'application/pdf':
        <object id="pasteobj" class="pure-u-1" data="{{file_external_src}}" type="application/pdf">
            <p>It looks like you don't have a plugin installed to view this paste. Try clicking <a href="{{file_external_src}}">this link</a> instead.</p>
        </object>
% end  # (if)

	</div>
    </div>
    <div class="pure-u-1 pure-u-lg-1-8"></div>
</div>
<script type="text/javascript">
document.getElementById("share-url").select();
</script>

% include(bottom)
% current_time = t.time()
% time_gen = t.strftime("%D %H:%M:%S", t.localtime(int(current_time)))
% timediff = current_time - start_time
<!-- Generated on {{time_gen}} GMT in {{timediff}} seconds. -->

